package com.dinfo.dmg.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dinfo.dmg.bean.MovieQuery;
import com.dinfo.dmg.bean.p_neg_site_info;
import com.dinfo.dmg.service.MovieShowService;


@Controller
public class MovieShowController {

	@Autowired
	private MovieShowService  movieShowService;
	
	@ResponseBody
	@RequestMapping("/test")
	public Map  testmap()
	{
		Map map = new HashMap<String, String>(){{put("dd", "dd");put("dd", "dd");}};
		return map;
	}
	
	@RequestMapping("/index")
	public String index()
	{
		
		return "/showmovie";
	}
	
	@RequestMapping("/showcharts")
	public String showCharts()
	{
		return "/showcharts";
	}
	
	@ResponseBody
	@RequestMapping("/showAllMovie")
	public Map<String,Object>   showAllMove(MovieQuery query,  int page , int rows)
	{
		page = page <0 ?0:page;
		int start = (page - 1) *rows;
		int end = page *rows;
		int total = movieShowService.selectAllCount(query);
		List data = movieShowService.selectAllData(query,start ,end);
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("total", total+"");
		map.put("rows", data);
		return map;
	}
	
	@ResponseBody
	@RequestMapping("/getMovieType")
	public List<Map<String,String>> getMovieType()
	{
		
		return movieShowService.selectMovieType();
	}
	
	
	@ResponseBody
	@RequestMapping("/getAllMovieName")
	public List<Map<String,String>> getAllMovieName()
	{
		return movieShowService.selectMovieName();
	}
	
	@ResponseBody
	@RequestMapping("/getMovieCount")
	public Map<String,Object> getMovieCount()
	{
		return movieShowService.selectMovieCount();
	}
	
	
}
